#include <../include/linklist.h>
#include <stdio.h>
#include <../include/gtest.h>
#include <string.h>
// include <wchar.h>
#include <stdlib.h>
// Add_fun fun_number[100];
Add_fun func_head, *func_tail = &func_head;
int number = 0;
struct fun_info info;

void add_function (fun fun_name, const char *name) {
    // fun_number[number].name = (char *)strdup(name);
    // fun_number[number++].fun_name = fun_name;
    Add_fun *temp = (Add_fun *)calloc(1, sizeof(Add_fun));
    temp->name = strdup(name);
    temp->fun_name = fun_name;
    func_tail->p.next = &(temp->p);
    func_tail = temp;
}

int RUN_ALL_TESTS() {
    // for (int i = 0; i < number; i++) {
    for (struct Link_node *p = func_head.p.next; p; p = p->next) {
        Add_fun *fun_name = Head(p, Add_fun, p);
        printf(D_GREEN([====RUN====]   )"   " GREEN_HL( %s\n), fun_name->name);
        // printf(D_GREEN([====RUN====]   )"   " GREEN_HL( %s\n), fun_number[i].name);
        info.total = 0, info.success = 0;
        fun_name->fun_name();
        // fun_number[i].fun_name();
        printf(BLUE([  %8.2lf%%    ]  ) "   " BLUE_HL( %s) "  success: %lld  total: %lld\n\n", 1.0 * info.success / (info.success + info.total) * 100, fun_name->name, info.success, info.total);
        //printf(BLUE([  %8.2lf%%    ]  ) "   " BLUE_HL( %s) "  success: %lld  total: %lld\n\n", 1.0 * info.success / (info.success + info.total) * 100, fun_number[i].name, info.success, info.total);
    }
    return 0;
}
